package udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UdpClient {
	public static void main(String[] args) throws IOException {
		DatagramSocket socket = new DatagramSocket();
		InetAddress address = InetAddress.getByName("127.0.0.1");
		DatagramPacket packet = new DatagramPacket("abc".getBytes(), 0, 3, address, 8002);
		socket.send(packet);
		
		DatagramPacket p1= new DatagramPacket(new byte[3], 3);
		socket.receive(p1);
		String s = new String(p1.getData(), 0, p1.getLength());
		System.out.println(s);
		
		socket.close();
	}
}
